﻿
@page "/Wms/OtherInWarehouseDetail/BatchEdit"
@using nERP.ViewModel.Wms.OtherInWarehouseDetailVMs
@using System.ComponentModel.DataAnnotations
@inherits BasePage

<ValidateForm @ref="vform" Model="@Model" OnValidSubmit="@Submit">
  <div style="margin-bottom:10px;"> @WtmBlazor.Localizer["Sys.BatchEditConfirm"]</div>
  <Row ItemsPerRow="ItemsPerRow.Two" RowType="RowType.Normal">
    <BootstrapInput @bind-Value="@Model.LinkedVM.Seq"/>
    <Select @bind-Value="@Model.LinkedVM.OtherInWarehouseId" Items="AllOtherInWarehouses" Id="ga9402f7b84d94b80b08f74894d7e77c0"/>
    <Select @bind-Value="@Model.LinkedVM.WarehouseId" Items="AllWarehouses" Id="gf39e9d3d40f94e5284b90eca88c5a362"/>
    <Select @bind-Value="@Model.LinkedVM.GoodsId" Items="AllGoodss" Id="g7eb79e03819142c399e234bc5fcae2a2"/>
    <BootstrapInput @bind-Value="@Model.LinkedVM.GoodsName"/>
    <BootstrapInput @bind-Value="@Model.LinkedVM.GoodsSpec"/>
    <BootstrapInput @bind-Value="@Model.LinkedVM.GoodsUnit"/>
    <BootstrapInput @bind-Value="@Model.LinkedVM.OtherInNumber"/>
    <BootstrapInput @bind-Value="@Model.LinkedVM.Remark"/>
  </Row>

  <div class="modal-footer table-modal-footer">
    <Button ButtonType="ButtonType.Submit" IsAsync="true" Text="@WtmBlazor.Localizer["Sys.Submit"]"/>
    <Button OnClick="OnClose" Text="@WtmBlazor.Localizer["Sys.Close"]"/>
  </div>

</ValidateForm>



@code {
    [Parameter]
    public string id { get; set; }
    [Parameter]
    public string[] ids { get; set; }
    private OtherInWarehouseDetailBatchVM Model = new OtherInWarehouseDetailBatchVM();
    private ValidateForm vform { get; set; }
    
    private async Task Submit(EditContext context)
    {
        Model.Ids = ids;
        await PostsForm(vform, "/api/Wms/OtherInWarehouseDetail/BatchEdit", (s) => WtmBlazor.Localizer["Sys.BatchEditSuccess", s], method: HttpMethodEnum.POST);
    }
            

    public void OnClose()
    {
        CloseDialog();
    }
    
    private List<SelectedItem> AllOtherInWarehouses = new List<SelectedItem>();
    private List<SelectedItem> AllWarehouses = new List<SelectedItem>();
    private List<SelectedItem> AllGoodss = new List<SelectedItem>();
    protected override async Task OnInitializedAsync()
    {
        
        
        AllOtherInWarehouses = await WtmBlazor.Api.CallItemsApi("/api/Wms/OtherInWarehouseDetail/GetOtherInWarehouses");
        AllOtherInWarehouses.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });
        AllWarehouses = await WtmBlazor.Api.CallItemsApi("/api/Wms/OtherInWarehouseDetail/GetWarehouses");
        AllWarehouses.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });
        AllGoodss = await WtmBlazor.Api.CallItemsApi("/api/Wms/OtherInWarehouseDetail/GetGoodss");
        AllGoodss.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });

        await base.OnInitializedAsync();
    }
}
